import {request} from "umi";

/** 创建do
 * /metaDO/getDetailByID */

export async function createDo(body, options) {
  const res = request('/doa/repo/do/create', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
  return res
}


/** 创建do
 * /repo/updateDo */

export async function updateDo(body, options) {
  const res = request('/doa/repo/do/update', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
  return res
}




/** 获取DO详情
 * GET 参数doID
 * /do/getDetailByID */

export async function getDetailByID(params, options) {
  const res = request('/doa/repo/do/getDetailByID', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    params: {...params},
    ...(options || {}),
  });
  return res
}

/** 删除DO
 * GET 参数doID
 * /do/doID */

export async function deleteDo(params, options) {
  const res = request('/doa/repo/do/delete', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    params: {...params},
    ...(options || {}),
  });
  return res
}


/** 根据用户ID查询DO
 * GET 参数userID，default为anonymous
 * /do/doID */

export async function getDOsByUser(params, options) {
  const res = request('/doa/repo/do/getByUser', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    params: {...params},
    ...(options || {}),
  });
  return res
}


/** 测试和reg的联通情况
 * GET 参数regID
 * /repo/testRegConnection */

export async function testRegConnection(params, options) {
  const res = request('/doa/repo/testRegConnection', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    params: {...params},
    ...(options || {}),
  });
  return res
}



/** 绑定reg
 * GET 参数regID，level，level为1表示托管，会上传元数据，2表示接入，分布式搜索
 * /repo/connectRemoteReg */

export async function connectRemoteReg(params, options) {
  const res = request('/doa/repo/connectRemoteReg', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    params: {...params},
    ...(options || {}),
  });
  return res
}




/** 获取repo信息
 * /repo/getRepoInfo */

export async function getRepoInfo(body, options) {
  const res = request('/doa/repo/getRepoInfo', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
  return res
}


/** 获取RemoteRegs信息
 * /repo/getRemoteRegs */

export async function getRemoteRegs(body, options) {
  const res = request('/doa/repo/getRemoteRegs', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
  return res
}



/** 获取连接的LRS信息
 * /repo/getLRSInfo */

export async function getLRSInfo(params, options) {
  const res = request('/doa/repo/getLRSInfo', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    params: {...params},
    ...(options || {}),
  });
  return res
}

/** 获取repo的stat信息
 * /repo/getStat */

export async function getStat(params, options) {
  const res = request('/doa/repo/getStat', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    params: {...params},
    ...(options || {}),
  });
  return res
}



